package com.zwy.springinner.listener;

import com.zwy.springinner.event.PayEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Slf4j
@Component
public class PayListener {

    @Async
    @EventListener(PayEvent.class)
    public void onApplicationEvent(PayEvent customEvent) throws InterruptedException {
        log.info("监听器接受消息：{}", customEvent.getMessage());
        TimeUnit.SECONDS.sleep(5);
        log.info("监听器接受消息处理完毕：{}", customEvent.getMessage());
    }
}
